package com.woniu;



import com.woniu.config.ChatService;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.MessageWindowChatMemory;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestClient;

/**
 * @Author: 马宇航
 * @Todo: 启动类，注册自己的Service包装类
 * @DateTime: 25/05/06/星期二 11:08
 * @Component: 成都蜗牛学苑
 **/
@SpringBootApplication
public class MCPClientApp {
    public static void main(String[] args) {
        SpringApplication.run(MCPClientApp.class, args);
    }
    @Bean//ToolCallbackProvider tools
    public ChatService chatService(ChatClient.Builder chatClientBuilder,
                                   ToolCallbackProvider tools
                                   //BookingTolls bookingTolls,
                                   ,ChatMemory chatMemory) {
        return new ChatService(chatClientBuilder, tools, chatMemory);
    }
    @Bean
    public RestClient.Builder restClientBuilder() {
        return RestClient.builder();
    }

    /**
     * 定义消息窗口的大小
     * 内存存储模式
     * @return
     */
    @Bean
    public ChatMemory chatMemory() {
        return MessageWindowChatMemory.builder() // 定义消息窗口的大小
                .maxMessages(20) // 最大消息数  记忆库中最多可以存储的消息数
                .build(); // 构建
    }
}


